//
// Copyright (c) 2011, Peter Lane
// Licensed under the Academic Free License version 3.0

package fan.swtChartWrapper;

import fan.fwt.*;
import fan.gfx.Color;
import fan.gfx.Font;
import fan.sys.*;
import org.eclipse.swtchart.ITitle;

public class TitlePeer {
  private ITitle _ititle = null;

  public static TitlePeer make (fan.swtChartWrapper.Title self) throws Exception {
    return new TitlePeer ();
  }

  public void setITitle (ITitle ititle) {
    _ititle = ititle;
    _ititle.setText (_text);
    _ititle.setVisible (_visible);
    _ititle.setFont (Fwt.get().font(_font));
    _ititle.setForeground (Fwt.get().color(_foreground));
  }

  // Str text := ""
  private String _text = "";
  public String text (fan.swtChartWrapper.Title self) { return _text; }
  public void text (fan.swtChartWrapper.Title self, String v) { 
    _text = v; 
    if (_ititle != null) _ititle.setText (_text);
  }

  private Font _font = Desktop.sysFont().toBold().toSize (11);
  public Font font (fan.swtChartWrapper.Title self) { return _font; }
  public void font (fan.swtChartWrapper.Title self, Font f) {
    _font = f;
    if (_ititle != null) _ititle.setFont (Fwt.get().font(_font));
  }

  private Color _foreground = Color.blue;
  public Color foreground (fan.swtChartWrapper.Title self) { return _foreground; }
  public void foreground (fan.swtChartWrapper.Title self, Color v) {
    _foreground = v;
    if (_ititle != null) _ititle.setForeground (Fwt.get().color(_foreground));
  }

  private boolean _visible = true;
  public boolean visible (fan.swtChartWrapper.Title self) { return _visible; }
  public void visible (fan.swtChartWrapper.Title self, boolean v) {
    _visible = v;
    if (_ititle != null) _ititle.setVisible (_visible);
  }
}
